import { Component } from 'react'
import Head from '../components/Head';
import {  Navigate } from 'react-router-dom'
import withRouter from '../util/withRouter';
class Login extends Component {

    state = {
        isLogin:false,
        pwd:'',
        name:''
    }

   
    handlerLogin = ()=>{
        console.log(this.state.name,this.state.pwd);
        // 编程式导航 在js代码当中实现跳转
        this.props.navigate('/') //实现跳转
    }   
    render(){
      
        return (
            <div>  
                我是登录页面
                <div>
                        <input 
                             placeholder='输入账号' 
                             value={this.state.name}
                             onChange={(ev)=> this.setState({name:ev.target.value}) }  
                        />  <br/>
                        <input  
                             placeholder='输入密码'
                             value={this.state.pwd}  
                             onChange={(ev)=> this.setState({pwd:ev.target.value}) } 
                        />
                        <button onClick={ this.handlerLogin }> 立即登录 </button>

                </div>
            </div>
        )
      
    }
}

export default withRouter(Login);